﻿using ImageDefine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ImageToolTransfer
{
    public partial class FormSetting : DevExpress.XtraEditors.XtraForm
    {
        ImageTask imageTask;
        ImageToolTransfer imageTool;
        ImageActionerTransfer imageActioner;
        public FormSetting()
        {
            InitializeComponent();
        }
        public FormSetting(ImageTask imageTaskIn, ImageToolTransfer imageToolIn, ImageActionerTransfer imageActionerIn)
        {
            InitializeComponent();
            imageTask = imageTaskIn;
            imageTool = imageToolIn;
            imageActioner = imageActionerIn;
        }

        private void FormSetting_Load(object sender, EventArgs e)
        {
            propertyGridControl1.SelectedObject = imageTool.Setting;
            imageTask.LoadRegeditFile(smartDisplayControl1);

            comboBoxEditFormName.Text = imageTool.strPositionName;
            comboBoxEditToName.Text = imageTool.strAngleName;
            foreach (ImageToolBase itemTool in imageTask.listTools)
            {
                if (itemTool is IPoint)
                {
                    comboBoxEditFormName.Properties.Items.Add(itemTool.Name);
                }
                if (itemTool is ILineTool)
                {
                    comboBoxEditToName.Properties.Items.Add(itemTool.Name);
                }

            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            imageTool.imageTask.LoadRegeditFile(smartDisplayControl1);

            imageTool.imageTask.RunFileImage(smartDisplayControl1, smartDisplayControl1.ho_Image);

            imageTool.Run(smartDisplayControl1.ho_Image, smartDisplayControl1);
        }

        private void simpleButtonLoadImage_Click(object sender, EventArgs e)
        {
            imageTool.imageTask.LoadRegeditFile(smartDisplayControl1);
        }

        private void comboBoxEditFormName_SelectedValueChanged(object sender, EventArgs e)
        {
            imageTool.strPositionName = comboBoxEditFormName.EditValue.ToString();
        }

        private void comboBoxEditToName_SelectedValueChanged(object sender, EventArgs e)
        {
            imageTool.strAngleName = comboBoxEditToName.EditValue.ToString();
        }
    }
}
